from lib.types import TDate

class Motor:

	def __init__(self, ws):
		self.ws = ws
		self.db = ws.db

	def run(self, parent, d):

		where = ['true']

		if d.get('cliente'):
			where.append("grid='%d'" % d['cliente'])
			
		sql = "select * from cliente where %s order by codigo, nome" % ' and '.join(where)
		rs = self.db.get_dict_result(sql)

		for r in rs:
			parent.feed(r)
